<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/page/public/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>需求列表</title>
<% request.setAttribute("menu", 1); %>
<%@ include file="/WEB-INF/page/public/contentmeta.jsp"%>
<link rel="stylesheet" href="<%=basePath%>plugins/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="<%=basePath%>css/global.css" media="all" />
<link rel="stylesheet" href="<%=basePath%>plugins/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="<%=basePath%>css/tab.css" media="all" />
<link rel="stylesheet" href="<%=basePath%>css/system.css?v=1" media="all">
<link rel="stylesheet" href="//at.alicdn.com/t/font_389729_ln4520tk0oo.css" media="all">
<script type="text/javascript" src="<%=basePath%>js/qualify/zizhisel.js"></script>
<script type="text/javascript" src="<%=basePath%>js/jobsel/job.js"></script>
<script type="text/javascript" src="<%=basePath%>js/clipboard.min.js"></script>
<style>
.site-table.TM-table3 th:first-child,
.site-table.TM-table3 td:first-child {
text-align: left;
}
</style>
</head>
<body>

<div class="admin-tab admin-user admin-transform">
    <div class="tab-condition">
        <form class="layui-form clefix" action="/customer/categoryneedurl" method="post" id="transformform">
            <div class="layui-form-item">
            	<div class="layui-input-inline">
	                  	<input type="text" name="keyWord" id="keyWord" class="layui-input" placeholder="请输入关键字"  style="width:100%" value="${pager.params.keyWord}"> 
	            </div>
			</div>
			<div class="layui-form-item">
	            <div class="layui-input-inline">
	            	<select name="type" id="type" lay-filter="type" class="typeclass">
                        <option value="">请选择资源类型</option>
                        <option value="-1" <c:if test="${pager.params.type == -1}">selected</c:if>>全部</option>
                        <option value="0" <c:if test="${pager.params.type == 0}">selected</c:if>>个人</option> 
                        <option value="1" <c:if test="${pager.params.type == 1}">selected</c:if>>企业</option> 
                    </select>
	            </div>
			</div>
			<div class="layui-form-item">
	            <div class="layui-input-inline">
	            	<select name="buystate" id="buystate" lay-filter="buystate" class="typeclass">
                        <option value="">请选择供求关系</option>
                        <option value="-1" <c:if test="${pager.params.buystate == -1}">selected</c:if>>全部</option>
                        <option value="0" <c:if test="${pager.params.buystate == 0}">selected</c:if>>卖</option> 
                        <option value="1" <c:if test="${pager.params.buystate == 1}">selected</c:if>>买</option> 
                    </select>
	            </div>
			</div>
			<%-- <div class="layui-form-item">
	            <div class="layui-input-inline">
					<input name="category" id="category" type="hidden" value="${pager.params.category}" >
					<input type="text" name="zizhiType" id="zizhiType" class="layui-input" style="width:100%" autocomplete="off"    placeholder="请选择需求证书">
	            </div>
			</div> --%>
			<div class="layui-form-item">
	            <div class="layui-input-inline">
	            	<select name="types" id="types" lay-filter="types" class="typeclass">
                        <option value="">请选择性质</option>
                        <option value="-1" <c:if test="${pager.params.types == -1}">selected</c:if>>全部</option>
                        <option value="1" <c:if test="${pager.params.types == 1}">selected</c:if>>初始</option>
                        <option value="2" <c:if test="${pager.params.types == 2}">selected</c:if>>转注册</option>
                        <option value="3" <c:if test="${pager.params.types == 3}">selected</c:if>>初转不限</option>
                        <option value="4" <c:if test="${pager.params.types == 3}">selected</c:if>>资质</option> 
                    </select>
	            </div>
			</div>
			<div class="layui-form-item">
	            <div class="layui-input-inline">
	            	<select name="paperspurpose" id="paperspurpose" lay-filter="paperspurpose" class="typeclass">
                        <option value="">请选择用途 </option>
                        <option value="-1" <c:if test="${pager.params.paperspurpose == -1}">selected</c:if>>全部</option>
                       <%--  <option value="0" <c:if test="${pager.params.paperspurpose == 0}">selected</c:if>>其他</option> --%>
                        <option value="1" <c:if test="${pager.params.paperspurpose == 1}">selected</c:if>>入库</option>
                        <option value="2" <c:if test="${pager.params.paperspurpose == 2}">selected</c:if>>项目</option>
                      <%--   <option value="3" <c:if test="${pager.params.paperspurpose == 3}">selected</c:if>>动态核查</option> --%>
                    </select>
	            </div>
			</div>
			<%-- <div class="layui-form-item">
	            <div class="layui-input-inline">
	            	<input type="text" style="width:170px;" name="stime" id="stime"  placeholder="起始时间" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})" value="${pager.params.stime}">
	            </div>
            </div>
            <div class="layui-form-item">
	            <div class="layui-input-inline">
	            	<input type="text" style="width:170px;" name="etime" id="etime"  placeholder="结束时间" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})" value="${pager.params.etime}">
	            </div>
            </div> --%>
            <div class="layui-form-item">
            	<input name="skipToPage" id="skipToPage"  type="hidden" value="${pager.pageNo}">
				<input type="hidden" id="pageNo" name="pageNo" value="${pager.pageNo}">
				<input type="hidden" id="totalPage" name="totalPage" value="${pager.totalPages}">
				<input type="hidden" id="pageSize" name="pageSize" value="${pager.pageSize}">
                <button class="layui-btn search" type="button" lay-submit="" lay-filter="search"><i class="layui-icon">&#xe615;</i>搜索</button>
                <button class="layui-btn cleanbtn"  type="button"><i class="layui-icon layui-unselect layui-tab-close ">&#xe640;</i>清空</button>  
            </div>
        </form>
        <div class="TM-tab-info">
           <c:if test="${sessionScope.user.id==1}"> <a class="layui-btn layui-btn-primary layui-btn-small fqbtn"><i class="layui-icon">&#x1006;</i>批量删除</a></c:if>
            <a class="layui-btn layui-btn-primary layui-btn-small refreshbtn"><i class="layui-icon">&#x1002;</i>刷新</a>
        </div>
    </div>
    <div class="layui-field-box">
        <table class="site-table table-hover TM-user TM-table3">
            <thead>
            <tr>
                <th style="width: 5%;"><input type="checkbox"
										id="selected-all" name="customcheck" /></th>
                <th style="width:10%">发起人</th> 
                <th style="width:29%">内容</th>
                <th style="width:5%">数量</th>
                <th style="width:6%">性质</th>
                <th style="width:6%;">用途</th>
               <!--  <th style="width:9%;">结束时间</th> -->
                <th style="width:34%;">备注</th>
                <th style="width:10%;">操作</th>
            </tr>
            </thead>
            <tbody>
            	<c:forEach var="obj" items="${pager.resultList}" varStatus="o1">
            		<tr>   
            			<td><input type="checkbox" name="customcheckbox"
											value="${obj.id}"  data-cusid="${obj.cusid}" /></td>
	            		<td  align="left">${obj.createusersname}</td>
	            		<td><c:if test="${obj.buystate==0}"><i class="iconfont icon-maichu " style="color:red;font-size: 19px;"></i></c:if><c:if test="${obj.buystate==1}"><i class="iconfont icon-mairu " style="color:#00e200;font-size: 19px;"></i></c:if>&nbsp;${obj.categoryname}（${obj.area}）</td>
	            		<td>${obj.count}本</td> 
	            		<td>
	            			<c:set property="types" var="types" value=""></c:set>
	            			<c:if test="${obj.types == 1}">
								初始
								<c:set property="types" var="types" value="初始"></c:set>
							</c:if>
							<c:if test="${obj.types == 2}">
								转注
								<c:set property="types" var="types" value="转注册"></c:set>
							</c:if>
							<c:if test="${obj.types == 3}">
								初转不限
								<c:set property="types" var="types" value="初始转注都可以"></c:set>
							</c:if>
							<c:if test="${obj.types == 4}">
								资质
								<c:set property="types" var="types" value="资质"></c:set>
							</c:if>
						</td>
	            		<td>
	            			<c:set property="paperspurpose" var="paperspurpose" value=""></c:set>
							<c:if test="${obj.paperspurpose == 1}">
								入库
								<c:set property="paperspurpose" var="paperspurpose" value="资质"></c:set>
							</c:if>
							<c:if test="${obj.paperspurpose == 2}">
			                	项目
			                	<c:set property="paperspurpose" var="paperspurpose" value="项目"></c:set>
			                </c:if>
	                		<c:if test="${obj.paperspurpose == 3}">
	                			动态核查
	                			<c:set property="paperspurpose" var="paperspurpose" value="动态核查"></c:set>
	                		</c:if>
	                		<c:if test="${obj.paperspurpose == 0}">
	                			其他
	                			<c:set property="paperspurpose" var="paperspurpose" value="其他"></c:set>
	                		</c:if>
	            		</td>
	            		<%-- <td>${obj.endtime.substring(0,10)}</td> --%>
	            		<td>${obj.remark}</td>
	            		<td>
	            				<c:if test="${obj.buystate==0}">
										 <c:if test="${obj.type==0}">
					            		     <button class="layui-btn layui-btn-mini layui-btn-primary  copybtn" data-clipboard-text='现有${obj.categoryname}${obj.count}本，可用于${paperspurpose}，要的速度联系${obj.createusersname}：${obj.phone}'>
											  <i class="layui-icon">&#xe609;</i>复制转发
											</button>
				            		     </c:if>
				            		       <c:if test="${obj.type==1}">
				            		     	<button class="layui-btn layui-btn-mini layui-btn-primary  copybtn" data-clipboard-text='现有${obj.categoryname}${obj.count}本，要的速度联系${obj.createusersname}：${obj.phone}'>
										  <i class="layui-icon">&#xe609;</i>复制转发
											</button>
				            		     </c:if>
								</c:if><c:if test="${obj.buystate==1}">
											 <c:if test="${obj.type==0}">
						            		     <button class="layui-btn layui-btn-mini layui-btn-primary  copybtn"  data-clipboard-text='${obj.area}急寻：${obj.categoryname}${types}，缺${obj.count}本，用于${paperspurpose}价格好谈，联系${obj.createusersname}：${obj.phone}'>
												  <i class="layui-icon">&#xe609;</i>复制转发
												</button>
					            		     </c:if>
					            		       <c:if test="${obj.type==1}">
					            		     	<button class="layui-btn layui-btn-mini layui-btn-primary  copybtn" data-clipboard-text='${obj.area}合作单位急寻：${obj.categoryname}${types}，缺${obj.count}本，用于${paperspurpose}价格好谈，联系${obj.createusersname}：${obj.phone}'>
											  <i class="layui-icon">&#xe609;</i>复制转发
												</button>
					            		     </c:if>
								</c:if>
	            		
	            		    
	            			
	            		</td>
            		</tr>
            	</c:forEach>
            </tbody>
        </table>
        <div class="admin-table-page">
            <div id="page" class="page"></div>
        </div>
    </div>
</div>
 
<script type="text/javascript">
   

layui.config({
    base: 'plugins/layui/modules/'
});

layui.use(['element','laypage','form','laydate','layer'], function() {
	
	var $ = layui.jquery,
    laypage = layui.laypage,
    layer = layui.layer;
	var form = layui.form();
	
	var jobselobj=   $("#zizhiType").jobsel({
       	'inputName' : "category"
	});
	jobselobj.init();
	

	//放弃按钮（多个）
	$(".fqbtn").on("click",function(){
		
		var id = $(this).attr("data");
		
		var value;
		//利用.each获取
		$("input:checkbox[name='customcheckbox']:checked").each(function(i){
			if (i == 0) {
				value = $(this).val();
			} else {
				value += ","+$(this).val();
			}
		});
		if (value == null || value == "") {
			 layer.msg("请选择一条或多条记录", {icon: 0});
			 return false;
		 }
		layer.confirm('确定删除吗？', function(index){

           
			$("input:checkbox[name='customcheckbox']:checked").each(function(i){
				 var idvalue = $(this).val();
				 var cusid = $(this).attr("data-cusid"); 
				 
				 $.ajax({
		      			type : "post",
		      			url : "/customer/deletecustomercategorybyid",
		      			data : {id:idvalue,cusid:cusid},
		      			dataType : "json",
		      			async:true,
		      			success : function(data){
		      				//layer.msg("需求删除成功",{time:700},function(){
							//	window.location.reload();
							//});
		      			}
		      		});
			});
			
			  $("#skipToPage").val(1);
			 $("#transformform").submit();
 
			layer.close(index);
		});   
	});
	
	 
	//全选，取消全选
	$("#selected-all").on("click",function(){
		if ($("#selected-all").is(":checked")) {
			$("[name='customcheckbox']").prop("checked",true);
		} else {
			$("[name='customcheckbox']").prop("checked",false);
		}
	});
	var clipboard = new Clipboard('.copybtn');
	  //复制成功触发的事件
	   clipboard.on('success', function(e) {
		   layer.msg('复制成功', {icon: 1});
	   	   //console.log(e);
	   });
	   //复制失败触发的事件
	   clipboard.on('error', function(e) {
		   layer.msg('复制失败', {icon: 2});
	  });
	
	//点击清空
	$(".cleanbtn").on("click",function(){
		$("#keyWord").val("");
		$("#category").val("");
		$("#type").val("");
		$("#zizhiType").val("");
		$("#types").val("");
		$("#paperspurpose").val("");
		$("#stime").val("");
		$("#etime").val("");
		form.render();
	});
	
	//点击搜索
	$(".search").on("click",function(){
		$("#skipToPage").val(1);
		$("#transformform").submit();
	});
    
	var pageNo = $("#pageNo").val();
	var totalPage = $("#totalPage").val();
     
	//page
    laypage({
        cont: 'page',
        curr: pageNo//'${pager.pageNo}'
        ,pages: totalPage//'${pager.totalPages}' //总页数
        ,
        groups: 5 //连续显示分页数
        ,
        jump: function(obj, first) {
            //得到了当前页，用于向服务端请求对应数据
            var curr = obj.curr;
            if(!first) {
            	$("#skipToPage").val(curr);
            	$("#transformform").submit();
            }
        }
    });
  
});

</script>

</body>
</html>